<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>

  </style>
</head>
<body>

<script>

  /*
  // 构造函数
  function Car(name, color) {
    this.name = name
    this.color = color
  }
  Car.prototype.price = `￥138888.00`
  Car.prototype.run = function () {
    console.log('时速160Km')
  }*/

  // const Car1 = class Car {
  class Car {
    constructor(name, color) {
      this.name = name
      this.color = color
      // this.price = price
    }
    count = 100
    get price() {
      return `￥548888.00`
    }
    set price(val) {
      // console.log(this)
      console.log(val)
    }
    run() {
      console.log(this.count)
      console.log(this)
      console.log('时速160Km')
    }
    add() {
      this.count++
    }
    // 静态方法、一般用在 class 本身
    static sayHi() {
      console.log(this) // 当前 class
      console.log('hi')
    }
  }
  // class 子类 extends 父类 {}
  // class 子类 extends 基类 {}
  class NewCar extends Car {
    constructor(name, color, brand) {
      super(name, color); // 获取父类的参数
      this.brand = brand
    }
  }

  let c1 = new Car('本田', '#fff')
  let c2 = new NewCar('大众', 'gray', '帕萨特')
  console.log(c1)
  console.log(c2)
  // c2.run()

  // Car.sayHi()
  // NewCar.sayHi()

  // console.log(Car)
  // console.log(NewCar)





  // console.log(typeof Car) // function

  // let fengtian = new Car('丰田', 'white')
  // let bmw = new Car('宝马', 'white', '￥548888.00')
  // console.log(Car.prototype)
  // console.log(fengtian)
  // console.log(bmw)
  // console.log('==================')
  // fengtian.add()
  // console.log(fengtian.count)

  // fengtian.run()
  // Car.sayHi()
  // fengtian.sayHi()

  // console.log(fengtian.price)
  // console.log(bmw.price)
  // fengtian.price = '￥349999.88'



  // console.log(fengtian.price())
  // fengtian.run()


  /*const f1 = function f() {

  }
  f1()*/



  // getter
  // document.querySelector('input').value
  // setter
  // document.querySelector('input').value = 'xxxx'


</script>
</body>
</html>